package com.sdx.console.ncode.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.beetl.sql.core.annotatoin.*;
import org.apache.commons.lang3.StringUtils;
import com.ibeetl.admin.core.util.ValidateConfig;
import com.sdx.service.ConfigService;

import org.beetl.sql.core.TailBean;
import java.math.*;

import com.ibeetl.admin.core.annotation.Dict;
import com.ibeetl.admin.core.entity.BaseEntity;

import com.sdx.common.utils.Utils;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;

/*
*
* gen by Spring Boot2 Admin 2019-11-05
*/
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@Data
@Table(name="")
public class RightNcode extends BaseEntity{

    //n码
    @NotNull(message = "ID不能为空", groups =ValidateConfig.UPDATE.class)
    @AssignID
    @Column(name = "n_code")
    private String nCode ;

    //租户Id
    private Integer tenantId;

    private Integer provinceId;

    //名称
    private String codeName ;

    //对应权益角色
    private Integer roleId ;

    //2、体验卡，4、正式会员卡
    private Integer nType ;

    //可用标记 1、可用，0、不可用
    private Integer nStatus ;

    //是否已经激活 1、已经激活，0、未激活
    private Integer isActived ;

    //激活用户
    private String customerId ;

    //激活时间
    private Date activedTime ;

    //有效截止期
    private Date expiredDate ;

    //删除标识 0、未删除  1、已删除
    private Integer delStatus ;

    //批次Id
    private Integer batchId ;

    //编号
    private String nNumber ;

    //有效天数
    private Integer validityDay ;

    //备注
    private String remark ;

    //创建人
    private Integer createdBy ;

    //创建人名称
    private String createdName ;

    //创建时间
    private Date createdTime ;

    //更新人
    private Integer updatedBy ;

    //更新人名称
    private String updatedName ;

    //更新时间
    private Date updatedTime ;

    private String numberStart;

    private String numberEnd;

    @ColumnIgnore
    @JsonIgnore
    private String activedTimeQuery;
    @ColumnIgnore
    @JsonIgnore
    private Date activedTimeStart;
    @ColumnIgnore
    @JsonIgnore
    private Date activedTimeEnd;
    public String getActivedTimeQuery(){
        return  activedTimeQuery;
    }
    public void setActivedTimeQuery(String activedTimeQuery ){
        this.activedTimeQuery = activedTimeQuery;
        Date[] timePair = Utils.parseQueryTime(activedTimeQuery);
        if (timePair!=null && timePair[0]!=null) {
            this.activedTimeStart = timePair[0];
        }
        if (timePair!=null && timePair.length==2 && timePair[1]!=null) {
            this.activedTimeEnd = timePair[1];
        }
    }
    public Date getActivedTimeStart(){
        return  activedTimeStart;
    }
    public void setActivedTimeStart(Date activedTimeStart ){
        this.activedTimeStart = activedTimeStart;
    }
    public Date getActivedTimeEnd(){
        return  activedTimeEnd;
    }
    public void setActivedTimeEnd(Date activedTimeEnd ){
        this.activedTimeEnd = activedTimeEnd;
    }
    @ColumnIgnore
    @JsonIgnore
    private String expiredDateQuery;
    @ColumnIgnore
    @JsonIgnore
    private Date expiredDateStart;
    @ColumnIgnore
    @JsonIgnore
    private Date expiredDateEnd;
    public String getExpiredDateQuery(){
        return  expiredDateQuery;
    }
    public void setExpiredDateQuery(String expiredDateQuery ){
        this.expiredDateQuery = expiredDateQuery;
        Date[] timePair = Utils.parseQueryTime(expiredDateQuery);
        if (timePair!=null && timePair[0]!=null) {
            this.expiredDateStart = timePair[0];
        }
        if (timePair!=null && timePair.length==2 && timePair[1]!=null) {
            this.expiredDateEnd = timePair[1];
        }
    }
    public Date getExpiredDateStart(){
        return  expiredDateStart;
    }
    public void setExpiredDateStart(Date expiredDateStart ){
        this.expiredDateStart = expiredDateStart;
    }
    public Date getExpiredDateEnd(){
        return  expiredDateEnd;
    }
    public void setExpiredDateEnd(Date expiredDateEnd ){
        this.expiredDateEnd = expiredDateEnd;
    }

}
